1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#![allow(non_camel_case_types, non_snake_case)]
use crate::co;
use crate::decl::*;
use crate::kernel::privs::*;
use crate::prelude::*;
use crate::user::ffi;
impl_handle! { HMONITOR;
/// Handle to a
/// [display monitor](https://learn.microsoft.com/en-us/windows/win32/winprog/windows-data-types#hmonitor).
}
impl user_Hmonitor for HMONITOR {}
/// This trait is enabled with the `user` feature, and provides methods for
/// [`HMONITOR`](crate::HMONITOR).
///
/// Prefer importing this trait through the prelude:
///
/// ```no_run
/// use winsafe::prelude::*;
/// ```
pub trait user_Hmonitor: Handle {
/// [`GetMonitorInfo`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getmonitorinfow)
/// function.
///
/// # Examples
///
/// ```no_run
/// use winsafe::{self as w, prelude::*};
///
/// let hmon: w::HMONITOR; // initialized somewhere
/// # let hmon = w::HMONITOR::NULL;
///
/// let mut mi = w::MONITORINFOEX::default();
/// hmon.GetMonitorInfo(&mut mi)?;
///
/// println!("{}", mi.szDevice());
/// # w::SysResult::Ok(())
/// ```
fn GetMonitorInfo(&self, mi: &mut MONITORINFOEX) -> SysResult<()> {
bool_to_sysresult(
unsafe { ffi::GetMonitorInfoW(self.ptr(), mi as *mut _ as _) },
)
}
/// [`MonitorFromPoint`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfrompoint)
/// function.
#[must_use]
fn MonitorFromPoint(pt: POINT, flags: co::MONITOR) -> HMONITOR {
unsafe {
HMONITOR::from_ptr(ffi::MonitorFromPoint(pt.x, pt.y, flags.raw()))
}
}
/// [`MonitorFromRect`](https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-monitorfromrect)
/// function.
#[must_use]
fn MonitorFromRect(rc: RECT, flags: co::MONITOR) -> HMONITOR {
unsafe {
HMONITOR::from_ptr(
ffi::MonitorFromRect(&rc as *const _ as _, flags.raw()),
)
}
}
}